<script>
	export default {
		onLaunch: function() {
			// uni.showLoading({
			// 	title: '加载中'
			// }); // 登录

			// uni.login({
			// 	success: res => {
			// 		// 发送 res.code 到后台换取 openId, sessionKey, unionId
			// 		this.globalData.getopenid(res.code);
			// 	}
			// });
		},
		globalData: {
			getopenid(code) {
				var _this = this;

				uni.request({
					url: this.post_url + '/api/wechat/getOpenid',
					//仅为示例，并非真实的接口地址
					data: {
						code: code
					},
					method: 'post',

					success(res) {
						console.log(res);

						// _this.getuser(res.data.openid);

						_this.openid = res.data.openid;
						uni.hideLoading();
					}

				});
			},

			getuser: function(openid) {
				var _this = this;

				uni.request({
					url: this.post_url + '/api/v1/userLogin',
					//仅为示例，并非真实的接口地址
					data: {
						openid: openid
					},
					method: 'post',

					success(res) {
						if (res.data.code == 1) {
							if (_this.user_login == 0) {
								_this.user_info = res.data.data;
								_this.user_login = 1;
							}
						}

						uni.hideLoading();
					}

				});
			},
			reguser: function() {},
			user_login: 0,
			user_info: '',
			// post_url: "https://yhz.axu9.com/",
			post_url:"https://aijiu.axu9.com/",
			code: '',
			openid: ''
		},
		methods: {}
	};
</script>
<style lang="scss">
	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	@import "uview-ui/index.scss";
</style>
<style>
	@import "./app.css";
	
</style>